package com.pxene.dmp.common;

import java.io.InputStreamReader;
import java.io.LineNumberReader;

public class ShellUtils {

	public static String executeShell(String shell) {
		StringBuilder result = new StringBuilder();
		Process process;
		try {
			ProcessBuilder builder = new ProcessBuilder("/bin/sh", "-c", shell);
			process = builder.start();
			InputStreamReader reader = new InputStreamReader(process.getInputStream());
			LineNumberReader input = new LineNumberReader(reader);
			String line;
			process.waitFor();
			while ((line = input.readLine()) != null) {
				result.append(line);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result.toString();
	}
	
}
